

var productName = "Windows Server 2008";
	

var shortName = "Server 2008 Inside Out";
	

var ISBN = "978-0-7356-2438-2";


function SetSubheader(page)
{
	var subheaderText;
	switch(page)
	{
		case "Welcome":
			subheaderText= "Welcome to the Windows Server 2008 Inside Out companion CD. Here you will find invaluable resources, including product information and extensions to Windows Server 2008.";
		break;
				
		case "Product Information":
			subheaderText="Explore the features and capabilities of Windows Server 2008 and use the product guides to help you optimize Windows Server 2008 in your enterprise.";
		break;
		
		case "Resources":
			subheaderText="Reference white papers, guides, webcasts, test labs and more to help you use and troubleshoot the features of Windows Server 2008.";
		break;
		
		case "Scripts":
			subheaderText="Use sample scripts to help you automate management and maintenance tasks.";
		break;
		
		case "Tools":
			subheaderText="Link to tools for IIS, PowerShell, System Center Data Operations, and more.";
		break;
		
		case "Sample Chapters":
			subheaderText="View sample chapters and preview content from other Windows Server 2008 books.";
		break;
		
		
		/*
		case "ADDITIONALTABNAME":
			subheaderText="DESCRIPTION OF NEW TAB";
		break;
		*/
		default:
			//TODO: We might just want the current page to be the default, but I need to leave this in for now for testing.
			alert("A subheader with an invalid ID of " + page + " was encountered. This needs to be fixed before the book is released.");
	}
	var subheader = document.getElementById("subheader");
	subheader.innerText = subheaderText;
}
//code by ICC for fixing "Browse CD Content link"

function browseCD(){
try
	{
		
		
	  var fso = new ActiveXObject("Scripting.FileSystemObject");
  	  var coll = new Enumerator(fso.Drives);
	  for (; !coll.atEnd(); coll.moveNext())  {
		var x = coll.item();
		if (x.DriveType == 4 && x.IsReady){	
			var drv = x.DriveLetter + ":"
			var ws = new ActiveXObject("WScript.Shell");
			ws.Run("explorer " + drv);
			break;
			}

		}

	}
	catch(exc)
	{
		var msg = "An error occured while trying to use the Browse CD contents feature. You'll need to perform this task manually.";
		alert(msg);
		return;
	}

}
	
function SetTitle()
{
	newTitle = parent.productName + " - " + seriesTitle;
	document.title = newTitle;
}
		
function SetExtendingTab()
{
		
}

function OpenExternalLink(href)
{
	var properties = "status=yes, toolbar=yes, location=yes, menubar=yes, resizable=yes, scrollbars=yes, title=yes";
	window.open(href, "IOPupup", properties);
}
	
/*function explorer(dir)
{
	try
	{
		var ws = new ActiveXObject("WScript.Shell");
		ws.Run("explorer " + dir);
	}
	catch(exc)
	{
		var msg = "An error occured while trying to use the Browse CD contents feature. You'll need to perform this task manually.";
		alert(msg);
		return;
	}
}*/

		
function SearchEBookPDF(eBookName)
{
	// First try creating a WS object. They may not have the required priveleges.
	var ws, currentDir, searchPhrase, cmd, msg, textBox;
	try 
	{
		ws = new ActiveXObject("WScript.Shell");
	}
	catch(exc)
	{
		msg = "An error occurred while trying to automatically search the eBook. You can try to open the eBook and perform a manual search.";
		alert(msg);
		return;
	}
	
	currentDir = ws.CurrentDirectory;			
	textBox = document.getElementById("searchText");
	searchPhrase = textBox.value;					
	if (searchPhrase == "")
	{
		alert("Please enter a search phrase");
		return;
	}
	
	// First try opening with Acrobat. 
	cmd = 'Acrobat /A "search=' + searchPhrase + '"' + ' '  + currentDir + "\\eBook\\" + eBookName;
	try
	{
		ws.Run(cmd);
	}
	catch(exc)
	{
		// Now try opening with Acrobat Reader
		cmd = 'AcroRd32 /A "search=' + searchPhrase + '"' + ' '  + currentDir + "\\eBook\\" + eBookName;
		try
		{
			ws.Run(cmd);
		}
		catch(exc)
		{
			msg = "An error occurred while trying to automatically search the eBook. You can try to open the eBook and perform a manual search.";
			alert(msg);
		}
	}	
}
	
function SetInnerWindowSize(width, height) 
{
	// I think since we're using HTA, we'll end up using IE regardless of whether another browser is set as the default, 
	// but just in case, I've included the following block for other browsers. 
	if (window.innerHeight != null)
	{
		window.innerWidth = width;
		window.innerHeight = height;
	}
	else
	{
		// browser may be in compliance mode, in which case we'll use document.documentElement.clientWidth (& clientHeight)
		var innerWidth, innerHeight;
		if (document && document.documentElement && document.documentElement.clientWidth)
		{
			innerWidth = document.documentElement.clientWidth;
			innerHeight = document.documentElement.clientHeight;		
		}
		// otherwise, use document.body.innerWidth (& innerHeight)
		else if (document && document.body && document.body.clientHeight)
		{
			innerWidth = document.body.clientWidth;
			innerHeight = document.body.clientHeight;
		}
		else
		{
			return;
		}
		var widthDelta = width - innerWidth;
		var heightDelta = height - innerHeight;
		if (widthDelta > 5 || heightDelta > 5 || widthDelta < 0 || heightDelta < 0)
		{
			window.resizeBy(widthDelta, heightDelta);
			var newInnerWidth = document.documentElement.clientWidth;
			var newInnerHeight = document.documentElement.clientHeight;
		}
	}
}
		
function SetTitle()
{
	newTitle = parent.productName + " - " + "Inside Out";
	document.title = newTitle;
}

function FP_swapImg() 
{
	var doc=document;
	var args=arguments;
	var elm, n;
		
	doc.$imgSwaps=new Array(); 
	for(n=2; n<args.length; n+=2) 
	{ 
		elm=FP_getObjectByID(args[n]);
		if(elm) {
			doc.$imgSwaps[doc.$imgSwaps.length]=elm; 
			elm.$src=elm.src; 
			elm.src=args[n+1]; 
		} 
	}
}
	
function FP_preloadImgs()
{
	var d=document;
	var a=arguments; 
	if(!d.FP_imgs) 
		d.FP_imgs=new Array();
	for(var i=0; i<a.length; i++) 
	{ 
		d.FP_imgs[i]=new Image; 
		d.FP_imgs[i].src=a[i]; 
	}
}
	
function FP_getObjectByID(id, o) {
	var c, el, els, f, m, n; 
	if(!o)
		o=document; 
	if(o.getElementById) 
		el=o.getElementById(id);
	else if(o.layers) 
		c=o.layers; 
	else if(o.all) 
		el=o.all[id]; 
	if(el) 
		return el;
 	if(o.id==id || o.name==id) 
 		return o; 
 	if(o.childNodes)
 		c=o.childNodes; 
 	if(c)
 	{
 		for(n=0; n<c.length; n++) 
 		{ 
 			el=FP_getObjectByID(id,c[n]);
 			if(el) 
 				return el; 
 		}
 	}
	f=o.forms; 
	if(f)
	{ 
		for(n=0; n<f.length; n++) 
		{ 
			els=f[n].elements; 
			for(m=0; m<els.length; m++)
			{ 
				el=FP_getObjectByID(id,els[n]);
				if(el) return el; 
			} 
		}
	}
	return null;
}
